{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7e241a9e-9f21-420f-8716-b5b7ce2fcb86",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "67ec17f6-fec5-4f32-8d52-367f042c280c",
   "metadata": {},
   "source": [
    "构造一个全为浮点数的全0数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "59868785-f5a6-4b46-956e-d8874f91e544",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0.])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e8dd9e7b-60df-444f-8595-8e5895401bbf",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0.],\n",
       "       [0., 0., 0.],\n",
       "       [0., 0., 0.]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros((3,3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1ea1fe7-b547-415c-aef3-863d742e97ee",
   "metadata": {},
   "source": [
    "构造全1数组(浮点数)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3544c4b0-54b6-48a0-aa33-867266292f6c",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1.],\n",
       "       [1., 1., 1.],\n",
       "       [1., 1., 1.]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones((3,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0bf816d6-4f8f-450b-9c6b-a16c8d100d10",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[8., 8., 8.],\n",
       "       [8., 8., 8.],\n",
       "       [8., 8., 8.]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones((3,3)) * 8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9df950e5-7052-43aa-8b3a-c25857ff1be2",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1.],\n",
       "       [1., 1., 1.],\n",
       "       [1., 1., 1.]], dtype=float32)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones((3,3), dtype = np.float32)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f7e55e8-e24f-4d56-bc38-21385e31ef6d",
   "metadata": {
    "tags": []
   },
   "source": [
    "创建一个随机数组矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b3128806-6a56-4964-ad58-b900c4fbda43",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0.])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.empty(3)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "044e1757-9102-4b87-959e-bf43a8301920",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1., 1., 1.])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.fill(1)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9a8c314d-a6d5-4447-a99b-aec3793781ab",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fang_array = np.array([1,2,3,4])\n",
    "fang_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8da3514d-10b7-4e56-a9d3-af43477a63dd",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros_like(fang_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9f04f051-7b23-4101-a8b6-4e3763a5bc2a",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 1, 1, 1])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.ones_like(fang_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "460ac8d6-82cc-493a-8ff1-17d3eff1ae63",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0., 0., 0.],\n",
       "       [0., 1., 0., 0., 0.],\n",
       "       [0., 0., 1., 0., 0.],\n",
       "       [0., 0., 0., 1., 0.],\n",
       "       [0., 0., 0., 0., 1.]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.identity(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b62b178d-b44a-4d3d-ae95-e42d7ecfabc3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
